Fix watch depth limit being inert on Windows (path separator)#7
Open
Osamaali313 wants to merge 1 commit into
Open
Fix watch depth limit being inert on Windows (path separator)#7Osamaali313 wants to merge 1 commit into
Osamaali313 wants to merge 1 commit into
Conversation
The recursive file watcher limits triggers to a depth of 2 by splitting the relative path on '/'. path.relative() returns backslash-separated paths on Windows, so the split yields a single segment, depth is always 1, and the `depth > 2` guard never fires — deeply-nested changes trigger actions the code intends to suppress. Extract the depth computation into a small helper that splits on either separator (no change to POSIX behavior) and add a regression test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The recursive file watcher (
src/sidecar/file-watcher.ts) is meant to ignore changes deeper than 2 path levels (comment: "Limit depth to 1 (direct children + 1 level of subdirectories)"). It computes depth by splitting apath.relative()result on the literal'/':On Windows,
path.relative()returns backslash-separated paths (a\b\c\deep.txt), sosplit('/')returns a single-element array →depthis always1→depth > 2never fires. The depth limit is completely inert on Windows, so deeply-nested file changes trigger Claude Code actions the code intends to suppress.Fix
Extract the depth computation into a small helper that splits on either separator (identical behavior on POSIX, correct on Windows), and reuse it in the watcher:
watchRelativeDepthis exposed via the existing_testingexport.Testing
Added a
watchRelativeDepthblock tosrc/sidecar/__tests__/file-watcher.test.tsusingpath.join(OS-native separators):Verified on Windows: with the old
split('/'), every path reports depth1so the 3- and 4-level cases are wrongly not skipped (test fails); with the fix they report depth 3/4 and are skipped (test passes). POSIX behavior is unchanged (/paths split identically).